#include <REGX52.H>

unsigned char Key_KBD_Num()
{
	unsigned char KeyNum=0;
	P4_4=0;P4_2=1;P3_5=1;P3_4=1;
	if(P3_0==0) KeyNum=7;
	if(P3_1==0) KeyNum=6;
	if(P3_2==0) KeyNum=5;
	if(P3_3==0) KeyNum=4;
	
	P4_4=1;P4_2=0;P3_5=1;P3_4=1;
	if(P3_0==0) KeyNum=11;
	if(P3_1==0) KeyNum=10;
	if(P3_2==0) KeyNum=9;
	if(P3_3==0) KeyNum=8;
	
	P4_4=1;P4_2=1;P3_5=0;P3_4=1;
	if(P3_0==0)KeyNum= 15;
	if(P3_1==0)KeyNum= 14;
	if(P3_2==0)KeyNum= 13;
	if(P3_3==0)KeyNum= 12;
	
	P4_4=1;P4_2=1;P3_5=1;P3_4=0;
	if(P3_0==0)KeyNum= 19;
	if(P3_1==0)KeyNum= 18;
	if(P3_2==0)KeyNum= 17;
	if(P3_3==0)KeyNum= 16;
	
	return KeyNum;
	
}

unsigned char Key_BTN_Num()
{
	unsigned char KeyNum=0;
	if(P3_0==0)KeyNum= 7;
	if(P3_1==0)KeyNum= 6;
	if(P3_2==0)KeyNum= 5;
	if(P3_3==0)KeyNum= 4;
	return KeyNum;
}